package com.sample.navigation.util;

import android.graphics.Color;
import android.view.View;
import android.view.Window;

public class WindowStyleUtil {
    public final static int WS_NORMAL = 0;
    public final static int WS_NO_STATUS  = 1;
    public final static int WS_NO_NAV = 2;
    public final static int WS_NO_NAV_STATUS = 3;
    public static void setWindowStyle(Window window, int style, boolean immersive){
        int flag = View.SYSTEM_UI_FLAG_VISIBLE;
        switch (style){
            case WS_NO_STATUS:{
                flag = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_FULLSCREEN;
                break;
            }
            case WS_NO_NAV:{
                flag = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
                break;
            }
            case WS_NO_NAV_STATUS:{
                flag = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        | View.SYSTEM_UI_FLAG_FULLSCREEN;
                break;
            }
            default:
                break;
        }
        if(immersive){
            flag = flag
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    |View.SYSTEM_UI_FLAG_IMMERSIVE;
        }
        window.getDecorView().setSystemUiVisibility(flag);
    }

    public static void setNavigationColor(Window window, int color){
        window.setNavigationBarColor(color);
    }

    public static void setStatusColor(Window window, int color){
        window.setStatusBarColor(color);
    }
}
